package com.cookman.gameobjects.ActionButtons;

import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.scenes.scene2d.InputListener;
import com.badlogic.gdx.scenes.scene2d.Touchable;
import com.cookman.actions.Action;
import com.cookman.gameobjects.AbstractGameObject;
import com.cookman.utils.AssetUtils;

/**
 * Created by Cookman on 16.09.14.
 */
public class ActionActor extends AbstractGameObject {

    protected float scale = 0.5f;
    protected Action action;

    public Action getAction() {
        return action;
    }

    protected Sprite actionIcon;

    public ActionActor(Action action) {
        super();
        this.action = action;
        actionIcon = AssetUtils.getActionSprite(action);
        setBounds(0, 0, scale, scale);
        //   addListener(mouseActorListener);
        setTouchable(Touchable.enabled);
    }

    @Override
    public void draw(Batch batch, float parentAlpha) {
        actionIcon.setX(getX());
        actionIcon.setSize(scale, scale * (actionIcon.getWidth() / actionIcon.getHeight()));
        batch.draw(actionIcon, getX(), 0, scale, scale);
    }

    @Override
    public void renderGUI(SpriteBatch batch) {
    }

    @Override
    public void renderShape(ShapeRenderer renderer) {
    }

    public void setInputListener(InputListener listener) {
        addListener(listener);
    }
}
